// home//pages/index_zhengshu_detail/index.js
const apis = require('../../../utils/api').apis;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    pageSize: 1,
    dataArr: [],
    industryId: 0,
    pages: 1,
    pageNo: 1,
    recommendList: [],
    isMy: null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
    // 推荐里边的点击事件
    listbox(e){
      var id = e.currentTarget.dataset.id
      console.log(id)
      wx.navigateTo({
        url:'/curriculum/pages/course/index?id='+id,
      })
    },
  onLoad: function (options) {
    this.setData({
      id: options.id,
      isMy: options.isMy
    })
    // console.log('接收', this.data.isMy,options.id, this.data.id)
    this.getData()
  },
  getData() {
    wx.showLoading({
      title: '加载中',
    })
    if (this.data.isMy=='true') {
      apis.userCertificationQueryById({
        id: Number(this.data.id),
        pageSize:10,
      }).then(res => {
        this.setData({
          dataArr: res.data.userCertification,
          recommendList: res.data.recommendCurriculumIpage.records
        })
        wx.hideLoading()
      })
    } else {
      apis.certificateQueryById({
        id: Number(this.data.id),
      }).then(res => {
        this.setData({
          dataArr: res.data,
          industryId: res.data.certificate.industryId
        })
        wx.hideLoading()
        this.getRecommend()
      })
    }

  },
  getRecommend() {
    apis.curriculumReplaceCurriculumRecommend({
      pages: this.data.pages,
      pageSize: 5,
      pageNo: this.data.pageNo,
      industryId: this.data.industryId
    }).then(res => {
      console.log(res.data)
      this.setData({
        recommendList: res.data.recommendCurriculumIpage.records,
        pages: res.data.recommendCurriculumIpage.pages,
        pageNo: res.data.recommendCurriculumIpage.current
      })
      console.log(this.data.recommendList)
    })
  },
  changeIt() {
    this.getRecommend()
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})